import VueRouter from 'vue-router'

//导入组件
import Login from '../pages/Login/login'
import Ordinaryuser from '../components/Ordinaryuser'
import Subject from '../pages/ordinaryuser/Subject'
import UserProgram from '../pages/ordinaryuser/UserProgram'
import Levelstatistics from '../pages/ordinaryuser/Levelstatistics'
import UHomePage from '../pages/ordinaryuser/UHomePage'
import Register from '../pages/Register/register'
import ProjectFormation from '../pages/ordinaryuser/projectFormation'
import TeacherLogin from '../components/TeacherLogin'
import HomePage from '../pages/teacherLogin/Homepage'
import Object from '../pages/teacherLogin/Object'
import Student from '../pages/teacherLogin/Student'
import ProjectItem from '../pages/teacherLogin/ProjectItem'
import Board from '../pages/teacherLogin/Board'
import ObjectNav from '../pages/teacherLogin/ObjectNav'
import Diedai from '../pages/ordinaryuser/diedai'
import Userstory from '../pages/ordinaryuser/Userstory'
import Items from '../pages/ordinaryuser/Items'
import StoryPoint from '../pages/ordinaryuser/StoryPoint'
import PManagement from '../pages/teacherLogin/PManagement'
import Stage from '../pages/teacherLogin/Stage'
import Checkpoints from '../pages/teacherLogin/Checkpoints'
import MessageProcess from '../pages/teacherLogin/MessageProcess'
import CheckProcess from '../pages/teacherLogin/CheckProcess'
import DelayProcess from '../pages/teacherLogin/DelayProcess'
import Authoritymanage from '../pages/teacherLogin/Authoritymanage'
import Character from '../pages/teacherLogin/Character'
import ActiveUser from '../pages/teacherLogin/ActiveUser'
import PermissionList from '../pages/teacherLogin/PermissionList'
import EditeUsertotal from '../pages/teacherLogin/EditeUsertotal'
import Permission from '../pages/ordinaryuser/permission'
import FirstindexForm from '../pages/ordinaryuser/FirstindexForm'
import UserInfo from '../pages/ordinaryuser/UserInfo'
// 创建并暴露一个路由器

const router = new VueRouter({

    routes: [
        {
            //通过路由重定向,页面访问跟路径的时候重定向到login组件
            path: '/', redirect: '/login'
        },
        {
            name: 'login',
            path: '/login',
            component: Login,
        },
        {
            name: 'register',
            path: '/register',
            component: Register,
        },
        {
            name: 'ordinaryuser',
            path: '/Ordinaryuser',
            component: Ordinaryuser,
            meta: {
                isAuth: true
            },
            beforeEnter: (to, from, next) => {
                if (localStorage.getItem('token')) {
                    next()
                } else {
                    next({ path: '/login' })
                }
            },
            children: [
                {
                    // 通过路由重定向,页面访问跟路径的时候重定向到login组件
                    path: '/Ordinaryuser', redirect: 'UHomePage'
                },
                {
                    name: 'Subject',
                    path: 'Subject',
                    component: Subject,
                },
                {
                    name: 'UserProgram',
                    path: 'UserProgram',
                    component: UserProgram,
                },
                {
                    name: 'Levelstatistics',
                    path: 'Levelstatistics',
                    component: Levelstatistics
                },
                {
                    name: 'UHomePage',
                    path: 'UHomePage',
                    component: UHomePage,
                },
                {
                    name: 'ProjectFormation',
                    path: 'ProjectFormation',
                    component: ProjectFormation,
                },
                {
                    name: 'UserInfo',
                    path: 'UserInfo',
                    component: UserInfo,
                },
                {
                    name: 'Items',
                    path: 'Items',
                    component: Items,
                    children: [
                        {
                            path: '/Ordinaryuser/Items', redirect: 'Diedai'
                        },
                        {
                            name: 'Diedai',
                            path: 'Diedai',
                            component: Diedai,
                        },
                        {
                            name: 'Userstory',
                            path: 'Userstory',
                            component: Userstory,
                        },
                    ]
                },
                {
                    name: 'StoryPoint',
                    path: 'StoryPoint',
                    component: StoryPoint,
                },
                {
                    name: 'Permission',
                    path: 'Permission',
                    component: Permission
                },
                {
                    name: 'FirstindexForm',
                    path: 'FirstindexForm',
                    component: FirstindexForm
                }
            ],

        },
        {
            name: 'teacherLogin',
            path: '/TeacherLogin',
            component: TeacherLogin,
            children: [
                {
                    path: '/TeacherLogin', redirect: 'Homepage'
                },
                {
                    name: 'Homepage',
                    path: 'Homepage',
                    component: HomePage,
                    meta: { title: '首页' }
                },
                {
                    name: 'ObjectNav',
                    path: 'ObjectNav',
                    component: ObjectNav,
                    meta: { title: '资源管理' },
                    children: [
                        {
                            path: '/TeacherLogin/ObjectNav', redirect: 'Object'
                        },
                        {
                            name: 'Object',
                            path: 'Object',
                            component: Object,
                            meta: { title: '学科管理', type: 1 }
                        },
                        {
                            name: 'Stage',
                            path: 'Stage',
                            component: Stage,
                            meta: { title: '阶段管理', type: 1 }
                        },
                        {
                            name: 'Checkpoints',
                            path: 'Checkpoints',
                            component: Checkpoints,
                            meta: { title: '关卡、项目管理', type: 1 }
                        }
                    ]
                },
                {
                    name: 'PManagement',
                    path: 'PManagement',
                    component: PManagement,
                    meta: { title: '人员管理' },
                    children: [
                        {
                            path: '/TeacherLogin/PManagement', redirect: 'Student'
                        },
                        {
                            name: 'Student',
                            path: 'Student',
                            component: Student,
                            meta: { title: '用户管理', type: 1 }
                        },
                        {
                            name: 'ActiveUser',
                            path: 'ActiveUser',
                            component: ActiveUser,
                            meta: { title: '用户激活', type: 1 }
                        }
                    ]
                },
                {
                    name: 'MessageProcess',
                    path: 'MessageProcess',
                    component: MessageProcess,
                    meta: { title: '消息处理' },
                    children: [
                        {
                            path: 'TeacherLogin/MessageProcess', redirect: 'CheckProcess'
                        },
                        {
                            name: 'CheckProcess',
                            path: 'CheckProcess',
                            component: CheckProcess,
                            meta: { title: '验收处理', type: 1 }
                        },
                        {
                            name: 'DelayProcess',
                            path: 'DelayProcess',
                            component: DelayProcess,
                            meta: { title: '延期处理', type: 1 }
                        }
                    ]
                },     
                {
                    name: 'Authoritymanage',
                    path: 'Authoritymanage',
                    component: Authoritymanage,
                    meta: { title: '权限管理' },
                    children: [
                        {
                            path: 'TeacherLogin/Authoritymanage', redirect: 'Character'
                        },
                        {
                            name:'Character',
                            path: 'Character',
                            component: Character,
                            meta:{title:'角色列表',type:1}
                        },
                        {
                            name:'PermissionList',
                            path: 'PermissionList',
                            component: PermissionList,
                            meta:{title:'权限列表',type:1}
                        }
                    ]

                },
                {
                    name: 'ProjectItem',
                    path: 'ProjectItem',
                    component: ProjectItem,
                    meta: { title: '项目', type: 1 }
                },
                {
                    name: 'Board',
                    path: 'Board',
                    component: Board,
                    meta: { title: '看板', type: 1 }
                },
                {
                    name: 'EditeUsertotal',
                    path: 'EditeUsertotal',
                    component: EditeUsertotal,
                    meta:{ title: '成员管理', type: 1 }
                }
            ]
        }

    ]
})

export default router
